﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

public class User
{
    public int UserId { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }
    public string Avatar { get; set; }
    public int Role { get; set; }
    public string Nickname { get; set; }
    
    // 导航属性，表示用户上传的书籍
    public ICollection<Book> UploadedBooks { get; set; }
    
    public ICollection<ReadingRecord> ReadingRecords { get; set; }

    
    // 静态方法用于配置实体
    public static void Configure(EntityTypeBuilder<User> builder)
    {
        builder.HasKey(u => u.UserId);
        builder.Property(u => u.UserId).ValueGeneratedOnAdd();
    }
}